// Author: Domien Nowicki

#ifndef MAPWIDGET_H
#define MAPWIDGET_H

#include <QWidget>
#include <QImage>
#include <QPen>
#include <QColor>
#include <QMouseEvent>
#include <QPoint>
#include <QPainter>
#include <QGraphicsView>
#include <QGraphicsScene>

#include <QWheelEvent>
#include "Map.h"
#include "MapLandItem.h"


class MapWidget : public QGraphicsView, public Map
{
	Q_OBJECT
public:

	// Constructors
	MapWidget(QWidget *parent = 0);
	MapWidget(const MapWidget& rhs);
	MapWidget(QWidget *parent, const Map& rhs);

	// Destructor
	virtual ~MapWidget();

	// Overloaded operations
	virtual Land* InsertNewLand(const std::string& name);
	virtual Land* InsertNewLand(const Land& land);
	virtual bool LoadFromFile(const std::string& filename);

	// Set the map's cursor
	void SetCursor(const QCursor& cursor);
	
	// Qt overloaded functions
	QRectF boundingRect() const;
	void wheelEvent(QWheelEvent *e);
	void resizeEvent(QResizeEvent* e);
	void keyPressEvent(QKeyEvent *e);
	
protected:
	// Overloaded operations
	virtual Land* InsertLand(MapLandItem* item);

signals:
	// Signal for when a province was clicked
	void clickedProvince(Map*, Land*, Province*);
	void cursorChanged(const QCursor&);
private slots:
	void slotClickedProvince(Land *land, Province *province);


private:
	// Helper functions
	void scaleView(qreal scaleFactor);
	void InitializeScene();
	void Center();

	static const qreal CENTERSCALE;
};

#endif //MAPWIDGET_H
